//http://ejohn.org/blog/simple-javascript-inheritance
(function(){
  var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
  // The base Class implementation (does nothing)
  this.Class = function(){};
  
  // Create a new Class that inherits from this class
  Class.extend = function(prop) {
    var _super = this.prototype;
    
    // Instantiate a base class (but only create the instance,
    // don't run the init constructor)
    initializing = true;
    var prototype = new this();
    initializing = false;
    
    // Copy the properties over onto the new prototype
    for (var name in prop) {
      // Check if we're overwriting an existing function
      prototype[name] = typeof prop[name] == "function" && 
        typeof _super[name] == "function" && fnTest.test(prop[name]) ?
        (function(name, fn){
          return function() {
            var tmp = this._super;
            
            // Add a new ._super() method that is the same method
            // but on the super-class
            this._super = _super[name];
            
            // The method only need to be bound temporarily, so we
            // remove it when we're done executing
            var ret = fn.apply(this, arguments);        
            this._super = tmp;
            
            return ret;
          };
        })(name, prop[name]) :
        prop[name];
    }
    
    // The dummy class constructor
    function Class() {
      // All construction is actually done in the init method
      if ( !initializing && this.init )
        this.init.apply(this, arguments);
    }
    
    // Populate our constructed prototype object
    Class.prototype = prototype;
    
    // Enforce the constructor to be what we expect
    Class.prototype.constructor = Class;

    // And make this class extendable
    Class.extend = arguments.callee;
    
    return Class;
  };
})();
var Helper = Class.extend
(
	{
		getFlashAd:function(movieName)
		{
			if (navigator.appName.indexOf("Microsoft") != -1) 
			{
				return window[movieName];
			} 
			else 
			{
				return document[movieName];
			}
		},
		getFlashMarkup:function(width, height, file, id)
		{
			var w = width;
			var h = height;
			var f = file;
			var s = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="' + w + '" height="' + h + '" id="' + id + '" align="middle">' +
					'<param name="movie" value="' + f + '" />' + 
					'<param name="quality" value="high" />' + 
					'<param name="bgcolor" value="#ffffff" />' + 
					'<param name="play" value="true" />' + 
					'<param name="loop" value="true" />' + 
					'<param name="wmode" value="window" />' + 
					'<param name="scale" value="showall" />' + 
					'<param name="menu" value="false" />' + 
					'<param name="devicefont" value="false" />' + 
					'<param name="salign" value="" />' + 
					'<param name="allowScriptAccess" value="always" />' + 
					'<!--[if !IE]>-->' + 
					'<object type="application/x-shockwave-flash" data="' + f + '" width="' + w + '" height="' + h + '">' + 
						'<param name="movie" value="' + f + '" />' + 
						'<param name="quality" value="high" />' + 
						'<param name="bgcolor" value="#ffffff" />' + 
						'<param name="play" value="true" />' + 
						'<param name="loop" value="true" />' + 
						'<param name="wmode" value="window" />' + 
						'<param name="scale" value="showall" />' + 
						'<param name="menu" value="false" />' + 
						'<param name="devicefont" value="false" />' + 
						'<param name="salign" value="" />' + 
						'<param name="allowScriptAccess" value="always" />' + 
					'<!--<![endif]-->' + 
						'<a href="http://www.adobe.com/go/getflash">' + 
							'<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />' + 
						'</a>' + 
					'<!--[if !IE]>-->' + 
					'</object>' + 
					'<!--<![endif]-->' + 
				'</object>';
			return s;
		},
		getSandBoxRoot:function()
		{
			//BUG:
			var tmp = document;
			var pos;do
			{
				if(tmp.parent)
				{
					pos = tmp.parent;
					tmp = pos;
				}
			}
			while(tmp != pos);
			return pos;
		}
	}
);
var Ad = Class.extend
(
	{
		init:function()
		{
			this.uiContainerId = "";
			this.PUBLISHER_PATH = 'http://www.AdWorx.com/Publisher';
			this.h = new Helper();
		},
		setUiContainerId:function(value)
		{
			this.uiContainerId = value;
		},
		getUiContainerId:function(value)
		{
			return this.uiContainerId;
		},
		//For non-rich banners.
		countMetric:function(type)
		{
			var i = this.o.createElement("image");
			var s = this.PUBLISHER_PATH + "?containerId=n&action=" + type;
			switch(type)
			{
				case "impression":
					//Do nothing.
				break;
				case "clickThrough":
					s += "&id=0";
				break;
			}
			i.src = s;
			this.d.appendChild(i);
			this.d.removeChild(i);
		},
		//Override.
		onRender:function(){},
		onRemove:function(){}
	}
);